<?php
/**商铺表模型
 * @Author: 976123967@qq.com
 * @Date:   2014-08-31 11:43:11
 * @Last Modified by:   chen
 * @Last Modified time: 2014-08-31 16:57:20
 */
class ShopModel extends Model{
	// 指定表名
	public $table ='shop';



	/**
	 * [$validate 自动验证]
	 * @var array
	 */
	public $validate = array(
		// 商铺名称
		array('shopname','nonull','请输入商铺名称',2,3),
		array('shopname','maxlen:30','商铺名称不能超过30个字符',2,3),
		// 商铺地址
		array('shopaddress','nonull','请输入商铺地址',2,3),
		array('shopaddress','maxlen:30','商铺地址不能超过120个字符',2,3),
		// 地铁地址
		array('metroaddress','nonull','请输入地铁地址',2,3),
		array('metroaddress','maxlen:30','地铁地址不能超过120个字符',2,3),
		// 商铺电话
		array('shoptel','nonull','请输入商铺电话',2,3),
		// 坐标
		array('shopcoord','nonull','请输入商铺坐标',2,3)
	);


	/**
	 * [get_shop_all 所有的店铺]
	 * @return [type] [description]
	 */
	public function get_shop_all ($where=null,$limit=null)
	{
		return  $this->where($where)->limit($limit)->order('shopid desc')->select();
	}



	/**
	 * [add_shop 添加商铺]
	 */
	public function add_shop()
	{
		return  $this->add();
	}	

	/**
	 * [edit_shop 编辑商铺]
	 */
	public function edit_shop()
	{
		return  $this->update();
	}	

	/**
	 * [get_shop_one 查找单条商铺单条记录]
	 * @param  [type] $shopid [description]
	 * @return [type]         [description]
	 */
	public function get_shop_one($shopid)
	{
		return $this->find($shopid);
	}

	/**
	 * [del_shop 删除商铺]
	 * @param  [type] $shopid [description]
	 * @return [type]         [description]
	 */
	public function del_shop($shopid)
	{
		$this->delete($shopid);
		return true;
	}
}